// utils/header/header.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    isBack: String,
    statusBarHeight: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    isIphoneX: getApp().globalData.isIphoneX,
    statusBarHeight: '',
  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show: function () {
      var that = this
      wx.getSystemInfo({
        success: function (res) {
          // console.log(res)
          var windowHeight = res.windowHeight
          var screenHeight = res.screenHeight
          var statusBarHeight = res.statusBarHeight
          that.setData({
            height: screenHeight * 2,
            windowHeight: windowHeight,
            screenHeight: screenHeight,
            statusBarHeight: statusBarHeight
          })
        }
      })
      wx.getNetworkType({
        success: function (res) {
          // 返回网络类型, 有效值：
          // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
          var networkType = res.networkType
          // console.log(networkType)
          if (networkType == 'none') {
            wx.redirectTo({
              url: '../classification/network',
            })
          }
        }
      })
    },
    hide: function () { },
    resize: function () { },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    backurl: function () {
      wx.navigateBack({
        delta: 1,
      })
    },
  }
})